package com.wuliu.controller;

import com.wuliu.common.core.domain.ApiResult;
import com.wuliu.common.core.domain.PageResult;
import com.wuliu.system.domain.BasEmployee;
import com.wuliu.system.domain.BasTruckInfo;
import com.wuliu.system.domain.TspLoading;
import com.wuliu.system.domain.dto.BaseDto;
import com.wuliu.system.domain.dto.app.LoadingDto;
import com.wuliu.system.service.IBasEmployeeService;
import com.wuliu.system.service.IBasTruckInfoService;
import com.wuliu.system.service.ITspLoadingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 装车单Controller
 * 
 * @author realue
 * @date 2023-10-25
 */
@Api(tags = {"装车单控制器"})
@RestController
@RequestMapping("/app/loading")
public class TspLoadingController {
    @Resource
    private ITspLoadingService tspLoadingService;
    @Resource
    private IBasEmployeeService basEmployeeService;
    @Resource
    private IBasTruckInfoService basTruckInfoService;

    @GetMapping("/getLoadingList")
    @ApiOperation(value = "查询用户装车单", notes = "")
    public ApiResult<PageResult<TspLoading>> getLoadingList(BaseDto dto){
        return ApiResult.success(tspLoadingService.getLoadingList(dto));
    }

    @GetMapping("/getDrivers")
    @ApiOperation(value = "查询司机列表", notes = "")
    public ApiResult<List<BasEmployee>> getDrivers(){
        return ApiResult.success(basEmployeeService.getDrivers());
    }

    @GetMapping("/getTrucks")
    @ApiOperation(value = "查询车辆列表", notes = "")
    public ApiResult<List<BasTruckInfo>> getTrucks(){
        return ApiResult.success(basTruckInfoService.getTrucks());
    }

    @PostMapping("/createLoading")
    @ApiOperation(value = "创建装车单", notes = "")
    public ApiResult<Boolean> createLoading(@RequestBody @Validated LoadingDto dto){
        return ApiResult.success(tspLoadingService.createLoading(dto));
    }
}
